package com.yanqu.road.server.manger.activity.recycle;

import com.yanqu.road.entity.activity.ActivityInfo;
import com.yanqu.road.entity.activity.ActivityItemRecycleData;
import com.yanqu.road.entity.activity.jieshi.config.JieShiConfig;
import com.yanqu.road.entity.config.goods.GoodsInfo;
import com.yanqu.road.entity.enums.eActivityType;
import com.yanqu.road.entity.enums.eGamePlayerEventType;
import com.yanqu.road.server.gameplayer.module.activity.lottery.ActivityLotteryConfig;
import com.yanqu.road.server.manger.activity.ActivityMgr;
import com.yanqu.road.server.manger.activity.jieshi.JieShiMgr;
import com.yanqu.road.server.manger.activity.lottery.ActivityLotteryMgr;
import com.yanqu.road.server.manger.config.GoodsMgr;
import com.yanqu.road.utils.property.Property;
import com.yanqu.road.utils.property.PropertyHelper;

import java.math.BigInteger;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

public class PeerlessBeautyLotteryRecycleStrategy extends AbstractItemRecycleStrategy {
    @Override
    public void markNeedRecycleItem() {
        ActivityLotteryConfig config = ActivityLotteryMgr.getPeerlessBeautyLotteryConfig();
        if (config == null) {
            return;
        }
        ActivityInfo activityInfo = config.getActivityInfo();
        if (activityInfo != null) {
            List<String> paramList = new ArrayList<>();

            int recycleItemId = 0;
            Property cost = PropertyHelper.parseStringToProperty(config.getCost());
            for (Map.Entry<Integer, BigInteger> goodsAndCount : cost.getGoods().entrySet()) {
                recycleItemId = goodsAndCount.getKey();
                break;
            }
            long recycleTime = activityInfo.getEndShowTime() * 1000L + gapTime;
            paramList.add(String.valueOf(recycleItemId));
            paramList.add(String.valueOf(config.getEXCHANGE_SCORE_ITEM_ID()));
            paramList.add("1");
            paramList.add(activityInfo.getActivityName());
            ActivityItemRecycleMgr.addRecycleItemData(recycleItemId, activityType, 0, recycleTime, paramList);
        }
    }

    @Override
    public boolean isActivityRunning() {
        ActivityInfo activityInfo = JieShiMgr.getConfig().getActivityInfo();
        return ActivityMgr.activityInTime(activityInfo);
    }

    @Override
    protected void initActivityType() {
        activityType = eActivityType.PeerlessBeautyLotteryActivity.getValue();
    }

    @Override
    protected void doRecycle(long userId, ActivityItemRecycleData data) {
        item2Score(userId, data);
    }


}
